//
//  BackView.m
//  MMLOOK
//
//  Created by dllo on 15/10/12.
//  Copyright © 2015年 武俊娥. All rights reserved.
//

#import "BackView.h"

@interface BackView ()

@property(nonatomic, retain)UIButton *backButton;
@property(nonatomic, retain)UILabel *titleLabel;

@end

@implementation BackView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        
    self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.backButton.frame = CGRectMake(50, 10, 30, 30);
        [self.backButton setBackgroundImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
        [self.backButton addTarget:self action:@selector(backLast) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.backButton];
    
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self addSubview:self.titleLabel];
        [_titleLabel release];
        
        
    }
    
    return self;
}


-(void)setTitle:(NSString *)title
{
    if (_title != title) {
        [_title release];
        _title = [title retain];
    }
    
     CGRect rect = [title boundingRectWithSize:CGSizeMake(300, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    
    self.titleLabel.frame = CGRectMake([UIScreen mainScreen].bounds.size.height / 2 -rect.size.width / 2 , 10, rect.size.width, 30);
    self.titleLabel.text = title;
    
}

-(void)backLast
{
    [self.delegate backLastView];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
